/**
 * Copyright 2012 Fonfon.Xen
 * All rights reserved.
 * 
 * @project 
 * @author Xen
 * @version 1.0
 * @data 2012-4-15
 */
package com.guidecaptain.java.action;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.guidecaptain.core.base.action.BaseAction;
import com.guidecaptain.java.model.pojo.Incident;
import com.guidecaptain.java.model.vo.IncidentVO;
import com.guidecaptain.java.service.IncidentService;

/**
 * @author Xen
 * 
 */
@Controller
@Scope("prototype")
public class IncidentAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Logger LOG = Logger.getLogger(IncidentAction.class);

	@Autowired
	private IncidentService incidentService;

	private IncidentVO incidentVO = new IncidentVO();

	public String insertIncident() {
		incidentService.insertIncident(incidentVO);

		return "insert";

	}

	public String updateGudie() {
		incidentService.updateIncident(incidentVO);

		return "update";
	}

	public String queryIncidentById(){
		Incident incident=incidentService.queryIncidentById(incidentVO.getIncidentId());
		
		try {
			PropertyUtils.copyProperties(incidentVO, incident);

		} catch (Exception e) {
			LOG.error(e);
			return ERROR;
		}
		
		return "incident";
	}
	
	public String incidentByGuideId(){
		incidentVO.setIncidentList(incidentService.queryIncidentByGuideId(incidentVO.getGuideId()));
		
		return "guideIncident";
	}
	
	/**
	 * 查询事件信息
	 */
	public String incidentList() {
		incidentVO.setIncidentList(incidentService.queryIncidentList(incidentVO));

		return "incidentList";
	}

	/**
	 * @param
	 * @return
	 */
	@Override
	public Object getModel() {

		return incidentVO;
	}

}
